<?php

namespace App\Models;

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Eloquent\Model;

class User extends Model
{

    public function profile()
    {
        return $this->hasOne('App\Models\Profile','user_id','id');
    }

    public function topic(){
        return $this->hasMany('App\Models\TopicBbs', 'user_id', 'id')->with('tags');
    }

    public function getRole()
    {
        return $this->belongsToMany('App\Models\Role', 'role_user', 'user_id', 'role_id');
    }

    public function getTag()
    {
        return $this->belongsToMany('App\Models\Tag', 'user_tag', 'user_id', 'tag_id');
    }

    public function reply(){
        return $this->hasMany('App\Models\Reply', 'user_id', 'id')->with('user','topic');
    }

    public function vote(){
        return $this->hasMany('App\Models\Vote', 'user_id', 'id');
    }

    public function follow(){
        return $this->hasMany('App\Models\Follow', 'user_id', 'id');
    }

    public function another(){
        return $this->hasMany('App\Models\Follow', 'another_id', 'id');
    }

    public function remind(){
        return $this->hasMany('App\Models\Remind', 'user_id', 'id');
    }
}
